# Same tests as in src/builtins/exists.rs:test_evaluate_arguments()
# TODO: find a better way than to write "echo $?" between each test cases
exists
echo $?
exists foo bar
echo $?

exists --help
echo $?
exists --help unused params
echo $?


exists ""
echo $?
exists string
echo $?
exists "string with spaces"
echo $?
exists "-startswithdash"
echo $?


exists -a
echo $?
let emptyarray = []
echo @emptyarray
exists -a emptyarray
echo $?
let array = [ "element" ]
echo @array
exists -a array
echo $?
exists -a array
echo $?


exists -b
echo $?
let OLDPATH = $PATH
let PATH = testing/
echo "PATH = $PATH"
ls -1 $PATH
exists -b executable_file
echo $?
exists -b empty_file
echo $?
exists -b file_does_not_exist
echo $?
let PATH = $OLDPATH
echo "Reset PATH to old path"

exists -d
echo $?
exists -d testing/
echo $?
exists -d testing/empty_file
echo $?
exists -d does/not/exist
echo $?


exists -f
echo $?
exists -f testing/
echo $?
exists -f testing/empty_file
echo $?
exists -f does-not-exist
echo $?

fn testFunc a
  echo $a
end
exists --fn testFunc
echo $?

exists -s
echo $?
let emptyvar = ""
echo "emptyvar = $emptyvar"
exists -s emptyvar
echo $?
let testvar = "foobar"
echo "testvar = $testvar"
exists -s testvar
echo $?
drop testvar

exists --foo
echo $?
exists -x
echo $?

echo "testvar = $testvar"
echo This line should not be reached. Accessing an undefined variable is a programming error
